Ext.define('AmpleHarvest.objects.search.results.grid.cSavedQuery',
{
	extend				: 'Ext.grid.Panel',
	viewConfig			:
	{
		forceFit	: true
	},
	requires			:
	[
			'AmpleHarvest.DATA.Store.cManager',
			'Ext.grid.column.Action'
	],

	initComponent		: function()
	{
		var obj_This = this;

		//var m_obj_SearchWin = this.up('ampleharvest-objects-search-panel-csearch');
		
		
		this.store =  Ext.create('AmpleHarvest.DATA.Store.cManager'); 

		
		
		this.columns =
		[
				{
					xtype			: 'actioncolumn',
					width			: 20,
					fixed			: true,
					menuDisabled	: true,
					items			:
					[
							{
								tooltip	: 'Load Query',
								iconCls	: 'query-load',
								scope	: obj_This,
								handler	: function(obj_Grid, int_RowIndex,
										int_ColIndex)
								{
									var obj_Rec = this.store
											.getAt(int_RowIndex);
									this.ownerCt
											.load_Query(obj_Rec.data.q_string);
								}
							}
					]
				},
				{
					header		: 'Title',
					sortable	: true,
					flex		: 1,
					dataIndex	: 'q_title'
				}
		];

		this.callParent();

//		this.store.on('remove', function() {console.log('rem')});
//		this.store.on('update', function() {console.log('up')});
		
//		this.store.load();
//		Ext.Function.defer(function()
//		{
//			var m_obj_SearchWin = this.up('ampleharvest-objects-search-panel-csearch');
//			console.log(m_obj_SearchWin);
//			m_obj_SearchWin.on(
//							AmpleHarvest.eventHandler.cWindowEvents.C_STR_EVENT_SAVED_QUERY_CHANGED,
//							obj_This.refreshData, obj_This
//					);
//		}, 100
//		);

	},

	refreshData			: function()
	{
		// alert('refresh saved query grid');
		this.store.load();
	}

}
);